
#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <unistd.h>
#include <sys/types.h>
#include <functional>
#include "test.hpp"
#include <sys/wait.h>



//父进程管理的类
class pipe_test
{
public:
    pipe_test(int wf,int pid):_wf(wf),_pid(pid)
    {
        _name = "写端:" + std::to_string(_wf) + "目标进程pid:" + std::to_string(_pid); 
    }
    std::string Name()
    {
        return _name;
    }
    void Write(int cmd)
    {
        ::write(_wf,&cmd,sizeof(cmd));
    }
    //返回pid
    pid_t Pid()
    {
        return _pid;
    }
    void Close()
    {
        ::close(_wf);
    }
    ~pipe_test()
    {

    }
private:
    int _wf;//标识父进程写端
    pid_t _pid;//目标进程的pid
    std::string _name;//名称
};

#endif